#pragma once

#include <QtWidgets/QMainWindow>
#include "ui_MyTestEcho.h"
#include "../Include/HPSocket/HPSocket.h"
#include "../Include/HPSocket/SocketInterface.h"
#include "selfdefine.h"

class MyTestEcho : public QMainWindow, public CTcpPullClientListener
{
    Q_OBJECT
signals:
    void signal_widget_state(WidgetState state);
    void signal_log_msg(const QString&);
private slots:
    void on_pushButton_send_clicked();
    void on_pushButton_start_clicked();
    void on_pushButton_stop_clicked();

    void SetWidgetState(WidgetState state);
    void log_msg(const QString& info);
public:
    MyTestEcho(QWidget *parent = nullptr);
    ~MyTestEcho();
protected:
    virtual EnHandleResult OnClose(ITcpClient* pSender, CONNID dwConnID, EnSocketOperation enOperation, int iErrorCode);
    virtual EnHandleResult OnConnect(ITcpClient* pSender, CONNID dwConnID);
    virtual EnHandleResult OnHandShake(ITcpClient* pSender, CONNID dwConnID) { return HR_IGNORE; }
    virtual EnHandleResult OnReceive(ITcpClient* pSender, CONNID dwConnID, int iLength);
    virtual EnHandleResult OnSend(ITcpClient* pSender, CONNID dwConnID, const BYTE* pData, int iLength);

private:
    Ui::MyTestEchoClass ui;
    CTcpPullClientPtr m_client;
    WidgetState m_widget_state;
};
